﻿using System;
using System.Collections.Generic;
using NTiering.EventHandlers;
using NTiering.Mappers;
using NTiering.Models;
using NTiering.Validators;
namespace NTiering
{
    public interface IService
    {
        int AddEventHandler(EventHandlerTriggers trigger, IEventHandler handler);
        int AddEventHandler(EventHandlerTriggers trigger, Action<IEventContext> eventHandler);

        int AddMapper<Tfrom, Tto>()
            where Tfrom : class, IModel, new()
            where Tto : class, IModel, new();
        int AddMapper<Tfrom, Tto>(IMapper<Tfrom, Tto> mapper)
            where Tfrom : class, IModel, new()
            where Tto : class, IModel, new();

        int AddValidator<T>(IValidator<T> validator) where T : class, IDataModel;
        int AddValidator<T>(Func<T,IService, string> validator) where T : class, IDataModel;

        object MapToModel<T>(T uiModel) where T : IModel;

        void SearchFor<T>(NTiering.Search.ISearchContext context) where T : IUiModel;
        bool TryCreate<T>(T uiModel, List<string> errors) where T : IUiModel;
        bool TryDelete<T>(T uiModel, List<string> errors) where T : IUiModel;
        bool TryUpdate<T>(T uiModel, List<string> errors) where T : IUiModel;
    }
}
